package com.hliushi.state.example01_right;

/**
 * 黄灯状态
 *
 * @author: hliushi
 * @date: 2023/2/15 22:49
 **/
public class YellowLight implements State {

    @Override
    public void switchToRed(TrafficLight trafficLight) {
        trafficLight.setState(new RedLight());
        System.out.println("OK... 红灯亮起60秒");
    }

    @Override
    public void switchToGreen(TrafficLight trafficLight) {
        trafficLight.setState(new GreenLight());
        System.out.println("OK... 绿灯亮起30秒");
    }

    @Override
    public void switchToYellow(TrafficLight trafficLight) {
        throw new UnsupportedOperationException("已经是黄灯状态无须再切换!!!");
    }

    @Override
    public String currentState() {
        return "🟨";
    }
}
